<template>
  <div class="navBar" :class="{'isCollapse':getCollapse}">
    <h1 class="logo">
      <img class="img" src="@/assets/logo.png" alt="logo">
      <span v-show="!getCollapse">后台管理系统</span>
    </h1>
    <el-menu
        :router="true"
        class="el-menu-vertical-demo"
        background-color="#304156"
        text-color="#fff"
        :collapse="getCollapse"
        :unique-opened="true"
        :collapse-transition="false"
        active-text-color="#ffd04b">
      <div v-for="(item,id) in getMenuData" :key="id">
        <el-submenu :index="item.path" v-if="item.children">
          <template slot="title">
            <i :class="'el-icon-'+item.icon"></i>
            <span  v-show="!getCollapse">{{item.title}}</span>
          </template>
          <el-menu-item :index="itemx.path" v-for="(itemx,idx) in item.children" :key="idx">
            <i :class="'el-icon-'+itemx.icon"></i>
            <span  v-show="!getCollapse">{{itemx.title}}</span>
          </el-menu-item>
        </el-submenu>
        <el-menu-item :index="item.path" v-else>
          <i :class="'el-icon-'+item.icon"></i>
          <span slot="title" v-show="!getCollapse" >{{item.title}}</span>
        </el-menu-item>
      </div>
    </el-menu>
  </div>
</template>

<script>
import {mapGetters} from 'vuex'
export default {
  name: 'NavBarView',
  data() {
    return {

    }
  },
  methods: {
  },
  computed: {
    ...mapGetters('navOptions',['getCollapse']),
    ...mapGetters('userMenuData',['getMenuData'])
  }
}
</script>

<style lang="less" scoped>
    .navBar{
      background-color: #304156;
      width: 200px;
      height: 100%;
      transition: all .3s;
      &.isCollapse{
        width: 64px;
      }
      .logo{
        width: 200px;
        display: flex;
        padding-top: 5px;
        .img{
          width: 15px;
          height: 15px;
          padding-left: 25px;
        }
        span{
          display: inline-block;
          margin-left: 5px;
          font-size: 14px;
          width: 150px;
          color: #fff;
        }
      }
    }
</style>
